import { defineStore } from 'pinia'
import { reactive, computed } from 'vue'
import { CONST } from '@/meta/constant';

export const settingStore = defineStore('setting', () => {
	const oneXUI = reactive({
		themeMode: 'dark',
		colorPrimary: '#1677FF',
		uiMode:'side',
		sideCollapsed:false,
	});
	const themeOverrides = reactive({
		token: {
			colorPrimary: oneXUI.colorPrimary,
		},
	});
	const setThemeMode = function(themeMode) {
		oneXUI.themeMode = themeMode;
	}
	
	const setThemeColor = function(colorPrimary) {
		themeOverrides.token.colorPrimary = colorPrimary;
		oneXUI.colorPrimary = colorPrimary;
	}
	const iconColor = computed(()=> {
		if(oneXUI.themeMode == CONST.THEMEMODE.DARK) {
			return '#FFFFFF';
		} else {
			return oneXUI.colorPrimary;
		}
	})
	return { oneXUI,themeOverrides,setThemeMode,setThemeColor,iconColor}
},
{
	persist: true
}
);